﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Reviewer.Entities.Services;
using Reviewer.Business;

public partial class V2Controls_GameViewStatistics : System.Web.UI.UserControl
{
    private delegate DataSet CompileViewStatisticsDelegate(Int32? genre, Int32? format);

    private CompileViewStatisticsDelegate compileViewStatistics;

    private DataView statistics;
    private DataView statisticsLastWeek;
    private DataView statisticsPreviousTotal;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //DataSet set = HttpContext.Current.Cache["CompileViewStatistics"] as DataSet;
            //if (set == null)
            //{
            //    using (IGameViewService service = ServiceFactory.GameViewService)
            //    {
            //        set = service.CompileViewStatistics();
            //    }
            //    if (set != null)
            //    {
            //        //Add with expires every hour
            //        HttpContext.Current.Cache.Add("CompileViewStatistics", set, null, DateTime.Now.AddMinutes(60 - DateTime.Now.Minute + 1), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
            //    }
            //}

            //if (set != null)
            //{
            this.uiReItems.DataSource = ServiceFactory.GameViewService.CompileViewStatisticsByGenre(1);
                    // set;
                this.uiReItems.DataBind();
            //}
        }
    }

    public Int32? Genre { get; set; }
    public Int32? Format { get; set; }
}
